#ifndef __LINKED_LIST_H_190725__
#define __LINKED_LIST_H_190725__

#include <string.h>
#include <assert.h>

#ifndef ElementType
#define ElementType int
#endif

typedef struct LNode* PtrToLNode;
typedef PtrToLNode List;
struct LNode {
	ElementType data;
	List next;
};

List linked_list_create(ElementType data, List next);
List linked_list_free(List list);
List linked_list_find(List list, ElementType v);
ElementType linked_list_at(List list, int i);
List linked_list_insert(List list, int i, ElementType v);
List linked_list_delete(List list, int i);

List linked_list_create(ElementType data, List next) {
	List list = (List)malloc(sizeof(struct LNode));
	if (NULL == list)
		return NULL;
	list->data = data;
	list->next = next;
	return list;
}

List linked_list_free(List list) {
	List temp;
	while (list) {
		temp = list->next;
		free(list);
		list = temp;
	}
	return NULL;
}

#endif //__LINKED_LIST_H_190725__